package cn.demographic.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.demographic.dao.Address_cityMapper;
import cn.demographic.dao.Address_countyMapper;
import cn.demographic.dao.Address_provinceMapper;
import cn.demographic.dao.EmploymentMapper;
import cn.demographic.dao.FamilyMapper;
import cn.demographic.dao.LivinginformationMapper;
import cn.demographic.dao.MarriageMapper;
import cn.demographic.dao.SpouseMapper;
import cn.demographic.dao.UserMapper;
import cn.demographic.entity.Address_city;
import cn.demographic.entity.Address_county;
import cn.demographic.entity.Address_province;
import cn.demographic.entity.Employment;
import cn.demographic.entity.Family;
import cn.demographic.entity.Livinginformation;
import cn.demographic.entity.Marriage;
import cn.demographic.entity.Spouse;
import cn.demographic.entity.User;
import cn.demographic.service.DetailsService;
@Service
public class DetailsServiceImpl implements DetailsService {
	@Autowired
	private Address_cityMapper address_cityMapper;
	@Autowired
	private Address_countyMapper address_countyMapper;
	@Autowired
	private Address_provinceMapper address_provinceMapper;
	@Autowired
	private UserMapper userMapper;
	@Autowired
	private SpouseMapper spouseMapper;
	@Autowired
	private FamilyMapper familyMapper;
	@Autowired
	private MarriageMapper marriageMapper;
	@Autowired
	private EmploymentMapper employmentMapper;
	@Autowired
	private LivinginformationMapper livinginformationMapper;
	
	/**
	 * 查询流动人口详情
	 */
	@Override
	public Map<String, Object> DetailsFind(User user) {
		Map<String, Object> map = new HashMap<String,Object>();
		//个人信息
		User u=userMapper.findUser(user);
		//配偶信息
		Spouse spouse=spouseMapper.findSpouse(user);
		//同住家庭信息
		List<Family> familylist=familyMapper.findFamily(user);
		//计生信息
		Marriage marriage=marriageMapper.findMarriage(user);
		//就业信息
		Employment employment=employmentMapper.findEmployment(user);
		//居住信息
		Livinginformation livinginformation=livinginformationMapper.findLivinginformation(user);
		u.setSpouse(spouse);
		u.setFamily(familylist);
		u.setMarriage(marriage);
		u.setEmployment(employment);
		u.setLivinginformation(livinginformation);
		map.put("User", u);
		return map;
	}
	
	
	//根据code编码查询市的信息
	public Address_city findByCodeCity(String code) {
		return address_cityMapper.findByCode(code);
	};
	
	//根据code编码查询县信息
	public Address_county findByCodeCounty(String code){
		return address_countyMapper.findByCode(code);
	};
	
	//根据code编码查询省份信息
	public Address_province findByCodeProvince(String code){
		return address_provinceMapper.findByCode(code);
	};
}
